package com.azdebugit.spring.auto.enable.test1.conf;

import com.azdebugit.spring.auto.enable.test1.FormatTemplate;
import com.azdebugit.spring.auto.enable.test1.format.FormatProcessor;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

@Configuration
@Import(FormatAutoConfiguration.class)
public class TemplateAutoConfiguration {

    @Bean
    public FormatTemplate formatTemplate(FormatProcessor formatProcessor) {
        return new FormatTemplate(formatProcessor);
    }

    public static void main(String[] args) {
        AnnotationConfigApplicationContext context =
                new AnnotationConfigApplicationContext(TemplateAutoConfiguration.class);
        FormatTemplate bean = context.getBean(FormatTemplate.class);
        FormatProcessor formatProcessor = context.getBean(FormatProcessor.class);
        System.out.printf(bean.doFormat("111.1112356789111"));
        System.out.printf("%.2f",111.1112356789111f);
        System.out.println(formatProcessor.format("bbb"));
    }
}